﻿<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../StaticFiles/element-ui/element-ui.css">
  <link rel="stylesheet" href="../StaticFiles/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../styles/vue-page-common.css">
  <script src="../Scripts/vue.min.js"></script>
  <script src="../StaticFiles/element-ui/element-ui.js"></script>
  <script src="../Scripts/axios.min.js"></script>
  <script src="../StaticFiles/nprogress/nprogress.min.js"></script>
  <script src="../Scripts/dayjs.min.js"></script>
  <script src="../Scripts/axios.config.js"></script>
  <script src="../Scripts/datav.min.vue.js"></script>
  <script src="../Scripts/lodash.min.js"></script>
  <title>质量看板</title>
  <style>
    html {
      background-image: url(../images/bg.jpg);
      color: #fff;
    }

    .el-form-item__label {
      color: #fff;
    }

    .header-title {
      font-size: 24px;
    }

    .el-form-item {
      margin-bottom: 0 !important;
    }
  </style>
</head>

<body>
  <div id="app" style="padding:0 5px;" v-cloak>
    <el-row>
      <el-col :span="6"><img src="../images/aeec_logo.png" height="60" alt="黎阳LOGO" /></el-col>
      <el-col :span="12" class="header-title">{{title}}</el-col>
      <el-col :span="6" class="currentTime">{{currentTime}}</el-col>
    </el-row>

    <!-- 查询条件区 -->
    <el-form :inline="true" :model="queryInfo" ref="queryInfoRef" :label-position="'left'" :rules="rules">
      <el-form-item label="主制分厂:">
        <el-select v-model="queryInfo.factoryid" placeholder="请选择" filterable @change="factorySeletChange">
          <el-option v-for="f in factoryList" :key="f.factoryid" :label="f.factoryname" :value="f.factoryid">
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="筛选时间:" prop="selectdate">
        <el-date-picker v-model="queryInfo.selectdate" type="daterange" range-separator="至" value-format="yyyy-MM-dd"
          start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="handlerBtnSearch">查询</el-button>
      </el-form-item>
    </el-form>

    <!-- 第一行图表区 -->
    <el-row>
      <el-col :span="8">
        <dv-border-box-11 title="报废数统计">
          <div :style="{height: chartHeight + 'px',paddingTop:'40px'}" id="lossQtyChart"></div>
        </dv-border-box-11>
      </el-col>
      <el-col :span="8">
        <dv-border-box-11 title="超差数统计">
          <div :style="{height: chartHeight + 'px',paddingTop:'40px'}" id="defectQtyChart"></div>
        </dv-border-box-11>
      </el-col>
      <el-col :span="8">
        <dv-border-box-11 title="返修数统计">
          <div :style="{height: chartHeight + 'px',paddingTop:'40px'}" id="reworkQtyChart"></div>
        </dv-border-box-11>
      </el-col>
    </el-row>

    <!-- 第二行图表区 -->
    <el-row>
      <el-col :span="8">
        <dv-border-box-11 title="合格率">
          <div :style="{height: chartHeight + 'px',paddingTop:'40px'}" id="passRateChart"></div>
        </dv-border-box-11>
      </el-col>
      <el-col :span="8">
        <dv-border-box-11 title="一次交检合格率">
          <div :style="{height: chartHeight + 'px',paddingTop:'40px'}" id="YiCiJiaoJianHeGeLv"></div>
        </dv-border-box-11>
      </el-col>
      <el-col :span="8">
        <dv-border-box-11 title="成检合格率">
          <div :style="{height: chartHeight + 'px',paddingTop:'40px'}" id="finishCheckPassRate"></div>
        </dv-border-box-11>
      </el-col>
    </el-row>

    <el-dialog :title="chartDetail.title" :width="'98%'" :top="'10px'" :visible.sync="chartDetail.dialogVisiable">
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="chartDetail.dataList" stripe border>
        <el-table-column type="index" width="50"></el-table-column>
        <el-table-column label="批次号" prop="containername" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序" prop="workflowstepname" width="160" show-overflow-tooltip></el-table-column>
        <el-table-column label="工区" prop="workcentername" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="报工人" prop="reportemployeename" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="报工时间" prop="reportdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="报工数" prop="reportqty" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="检验人" prop="checkemployeename" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="检验时间" prop="checkdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="合格数" prop="passqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="success">{{scope.row.passqty}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="报废数" prop="lossqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.lossqty > 0">{{scope.row.lossqty}}</el-tag>
            <span v-else>{{scope.row.lossqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="超差数" prop="defectqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.defectqty > 0">{{scope.row.defectqty}}</el-tag>
            <span v-else>{{scope.row.defectqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="返修数" prop="reworkqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.reworkqty > 0">{{scope.row.reworkqty}}</el-tag>
            <span v-else>{{scope.row.reworkqty}}</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination @current-change="handleDetailCurrentChange" :current-page="chartDetail.queryInfo.currentPage"
        :page-size="chartDetail.queryInfo.pageSize" :page-sizes="[chartDetail.queryInfo.pageSize]"
        layout="prev,pager,next,jumper,sizes,total" :total="chartDetail.total">
      </el-pagination>
    </el-dialog>

    <!-- 一次交检合格率--批次明细 -->
    <el-dialog :title="yiCiJiaoJianHeGeLvDetail.title" :width="'98%'" :top="'10px'"
      :visible.sync="yiCiJiaoJianHeGeLvDetail.dialogVisiable">
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="yiCiJiaoJianHeGeLvDetail.dataList" stripe border>
        <el-table-column type="index" width="50"></el-table-column>
        <el-table-column label="零件号" prop="productname" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件名称" prop="productdescription" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="工区" prop="workcentername" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="批次号" prop="containername" show-overflow-tooltip></el-table-column>
        <el-table-column label="报废数" prop="lossqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.lossqty > 0">{{scope.row.lossqty}}</el-tag>
            <span v-else>{{scope.row.lossqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="超差数" prop="defectqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.defectqty > 0">{{scope.row.defectqty}}</el-tag>
            <span v-else>{{scope.row.defectqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="返修数" prop="reworkqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.reworkqty > 0">{{scope.row.reworkqty}}</el-tag>
            <span v-else>{{scope.row.reworkqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="status" width="100" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag :type="scope.row.status === '合格' ? 'success' : 'danger'">{{scope.row.status}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100px;">
          <template slot-scope="scope" v-if="scope.row.status === '不合格'">
            <el-link type="primary" @click="showNoPassSpecDetail(scope.row)">
              <i class="el-icon-view el-icon"></i>
              查看工序
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination @current-change="handleYiCiJiaoJianHeGeLvDetailCurrentChange"
        :current-page="yiCiJiaoJianHeGeLvDetail.queryInfo.currentPage"
        :page-size="yiCiJiaoJianHeGeLvDetail.queryInfo.pageSize"
        :page-sizes="[yiCiJiaoJianHeGeLvDetail.queryInfo.pageSize]" layout="prev,pager,next,jumper,sizes,total"
        :total="yiCiJiaoJianHeGeLvDetail.total">
      </el-pagination>
    </el-dialog>

    <!-- 一次交检合格率--批次工序明细（不分页） -->
    <el-dialog :title="noPassSpecDetail.title" :width="'98%'" :top="'10px'"
      :visible.sync="noPassSpecDetail.dialogVisiable">
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="noPassSpecDetail.dataList" stripe border>
        <el-table-column type="index" width="50"></el-table-column>
        <el-table-column label="工区" prop="workcentername" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="批次号" prop="containername" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件号" prop="productname" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件名称" prop="productdescription" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序" prop="workflowstepname" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="检验时间" prop="checkdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="检验员" prop="checkemployeename" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="报工时间" prop="reportdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="报工人" prop="reportemployeename" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="报工数" prop="reportqty" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="合格数" prop="passqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="success">{{scope.row.passqty}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="报废数" prop="lossqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.lossqty > 0">{{scope.row.lossqty}}</el-tag>
            <span v-else>{{scope.row.lossqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="超差数" prop="defectqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.defectqty > 0">{{scope.row.defectqty}}</el-tag>
            <span v-else>{{scope.row.defectqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="返修数" prop="reworkqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.reworkqty > 0">{{scope.row.reworkqty}}</el-tag>
            <span v-else>{{scope.row.reworkqty}}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <!-- 成检合格率明细 -->
    <el-dialog :title="finishCheckPassRateDetail.title" :width="'98%'" :top="'10px'"
      :visible.sync="finishCheckPassRateDetail.dialogVisiable">
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="finishCheckPassRateDetail.dataList" stripe border>
        <el-table-column type="index" width="50"></el-table-column>
        <el-table-column label="工区" prop="workcentername" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="批次号" prop="containername" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件号" prop="productname" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="零件名称" prop="productdescription" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="工序" prop="workflowstepname" width="120" show-overflow-tooltip></el-table-column>
        <el-table-column label="检验时间" prop="checkdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="检验员" prop="checker" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="报工时间" prop="reportdate" width="100" :formatter="splitDate"></el-table-column>
        <el-table-column label="报工人" prop="worker" width="80" show-overflow-tooltip></el-table-column>
        <el-table-column label="合格数" prop="acceptanceqty2" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="success">{{scope.row.acceptanceqty2}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="报废数" prop="lossqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.lossqty > 0">{{scope.row.lossqty}}</el-tag>
            <span v-else>{{scope.row.lossqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="超差数" prop="defectqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.defectqty > 0">{{scope.row.defectqty}}</el-tag>
            <span v-else>{{scope.row.defectqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="返修数" prop="reworkqty" width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.reworkqty > 0">{{scope.row.reworkqty}}</el-tag>
            <span v-else>{{scope.row.reworkqty}}</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="status" width="100" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag :type="scope.row.status === '合格' ? 'success' : 'danger'">{{scope.row.status}}</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination @current-change="handleFinishCheckPassRateDetailCurrentChange"
        :current-page="finishCheckPassRateDetail.queryInfo.currentPage"
        :page-size="finishCheckPassRateDetail.queryInfo.pageSize"
        :page-sizes="[finishCheckPassRateDetail.queryInfo.pageSize]" layout="prev,pager,next,jumper,sizes,total"
        :total="finishCheckPassRateDetail.total">
      </el-pagination>
    </el-dialog>
  </div>
  <script src="../Scripts/echarts/echarts-5.4.0.min.js"></script>
  <script type="module">
    import { getParams } from '../Scripts/hooks/useCommonMethod.js'
    import { barOption, colorList } from '../Scripts/hooks/chartConfig.js'
    import { getUserInfo, getFactoryListByCode } from '../Scripts/hooks/fetchAPI.js'
    import { prevWeek, thisWeek, nextWeek, prevMonth, thisMonth, nextMonth } from '../Scripts/hooks/useDateShortCut.js'
    import { splitDate } from '../Scripts/hooks/format.js'
    const app = new Vue({
      el: '#app',
      data: {
        splitDate,
        currentTime: '',
        loading: false,
        loadingText: '数据加载中...',
        queryInfo: { factoryid: '', factoryname: '', selectdate: '' },
        total: 0,
        dataList: [],
        factoryList: [],
        chartDetail: {
          dialogVisiable: false,
          queryInfo: { workcentername: '', seriesName: '', currentPage: 1, pageSize: 12 },
          dataList: [], total: 0, title: ''
        },
        // 一次交检合格率明细
        yiCiJiaoJianHeGeLvDetail: {
          dialogVisiable: false,
          queryInfo: { workcentername: '', seriesName: '', currentPage: 1, pageSize: 12 },
          dataList: [], total: 0, title: ''
        },
        // 一次交检不合格率--工序明细
        noPassSpecDetail: {
          dialogVisiable: false,
          queryInfo: { workcentername: '', seriesName: '' },
          dataList: [], title: ''
        },
        // 成检合格率明细
        finishCheckPassRateDetail: {
          dialogVisiable: false,
          queryInfo: { workcentername: '', seriesName: '', currentPage: 1, pageSize: 12 },
          dataList: [], total: 0, title: ''
        },
        userInfo: {},
        title: '',
        rules: { selectdate: [{ required: true, message: '筛选时间不能为空', trigger: 'change' }] },
        currentDialog: '',
        chartHeight: 360,
        chartRow: 2,
        pickerOptions: { shortcuts: [prevWeek, thisWeek, nextWeek, prevMonth, thisMonth, nextMonth] }
      },
      methods: {
        // 生成柱状图通用方法
        async getChartDataCommon(config) {
          const loadingOption = { text: '数据查询中...', effect: 'whirling', maskColor: 'transparent', textColor: '#fff', color: '#66b1ff' };
          echarts.dispose(document.getElementById(config.id));
          let chart = echarts.init(document.getElementById(config.id));
          chart.showLoading(loadingOption);
          const { data: { data, meta, total } } = await axios.post(`../handler/board/QualityDashBoard.ashx?action=${config.action}`, { type: `${config.action}`, ...config.data })
          echarts.dispose(document.getElementById(config.id));
          chart = echarts.init(document.getElementById(config.id));
          chart.hideLoading();
          return { chart, data };
        },
        // 查询明细通用方法
        async getDetailCommon(config) {
          this.loading = true;
          this.loadingText = '数据加载中...';
          const { data: { data, meta, total } } = await axios.post(`../handler/board/QualityDashBoard.ashx?action=${config.action}`, { type: config.action, ...config.data });
          this.loading = false;
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.chartDetail.dataList = data;
          this.chartDetail.total = total;
        },
        //报废数统计
        async getLossQtyChart() {
          let { data, chart } = await this.getChartDataCommon({ id: 'lossQtyChart', action: 'getLossQty', data: this.queryInfo });
          let arrWorkcenter = [], arrQty = [];
          if (!data) { return; }
          for (const i of data) {
            arrWorkcenter.push(i.workcentername);
            arrQty.push(i.lossqty);
          }

          let option = barOption({ isLableFormat: true, provideNumber: 4 });
          option.legend.data = ['报废数'];//设置图例文字
          option.xAxis.data = arrWorkcenter;//x轴数据
          option.yAxis[1].show = false;//隐藏第二y轴

          const { color, colorStops } = colorList.red;
          option.series[0] = _.merge(option.series[0], {
            name: '报废数',
            data: arrQty,
            label: { color: color },
            itemStyle: { color: { colorStops: colorStops } }
          });

          chart.setOption(option);
          chart.on('click', (params) => {
            if (params.value == 0) { return; }
            this.chartDetail.queryInfo.currentPage = 1;
            this.chartDetail.queryInfo.workcentername = params.name;
            this.chartDetail.queryInfo.seriesName = params.seriesName;
            this.chartDetail.title = `【${params.name}】【${params.seriesName}】明细`;
            this.chartDetail.dialogVisiable = true;
            this.getLossChartDetail();
          })
        },
        // 报废数明细
        async getLossChartDetail() {
          this.currentDialog = 'getLossChartDetail';
          this.getDetailCommon({ action: 'getLossChartDetail', data: { ...this.queryInfo, ...this.chartDetail.queryInfo } });
        },
        // 超差数统计
        async getDefectQtyChart() {
          let { data, chart } = await this.getChartDataCommon({ id: 'defectQtyChart', action: 'getDefectQty', data: this.queryInfo });
          let arrWorkcenter = [], arrQty = [];
          if (!data) { return; }
          for (const i of data) {
            arrWorkcenter.push(i.workcentername);
            arrQty.push(i.defectqty);
          }

          let option = barOption({ isLableFormat: true, provideNumber: 4 });
          option.legend.data = ['超差数'];//设置图例文字
          option.xAxis.data = arrWorkcenter;//x轴数据
          option.yAxis[1].show = false;//隐藏第二y轴

          const { color, colorStops } = colorList.red;
          option.series[0] = _.merge(option.series[0], {
            name: '超差数',
            data: arrQty,
            label: { color: color },
            itemStyle: { color: { colorStops: colorStops } }
          });

          chart.setOption(option);
          chart.on('click', (params) => {
            if (params.value == 0) { return; }
            this.chartDetail.queryInfo.currentPage = 1;
            this.chartDetail.queryInfo.workcentername = params.name;
            this.chartDetail.queryInfo.seriesName = params.seriesName;
            this.chartDetail.title = `【${params.name}】【${params.seriesName}】明细`;
            this.chartDetail.dialogVisiable = true;
            this.getDefectChartDetail();
          })
        },
        // 超差数明细
        async getDefectChartDetail() {
          this.currentDialog = 'getDefectChartDetail';
          this.getDetailCommon({ action: 'getDefectChartDetail', data: { ...this.queryInfo, ...this.chartDetail.queryInfo } });
        },
        // 返修统计
        async getReworkQtyChart() {
          let { data, chart } = await this.getChartDataCommon({ id: 'reworkQtyChart', action: 'getReworkQty', data: this.queryInfo });
          let arrWorkcenter = [], arrQty = [];
          if (!data) { return; }
          for (const i of data) {
            arrWorkcenter.push(i.workcentername);
            arrQty.push(i.reworkqty);
          }

          let option = barOption({ isLableFormat: true, provideNumber: 4 });
          option.legend.data = ['返修数'];//设置图例文字
          option.xAxis.data = arrWorkcenter;//x轴数据
          option.yAxis[1].show = false;//隐藏第二y轴

          const { color, colorStops } = colorList.red;
          option.series[0] = _.merge(option.series[0], {
            name: '返修数', data: arrQty,
            label: { color: color },
            itemStyle: { color: { colorStops: colorStops } }
          });

          chart.setOption(option);
          chart.on('click', (params) => {
            if (params.value == 0) { return; }
            this.chartDetail.queryInfo.currentPage = 1;
            this.chartDetail.queryInfo.workcentername = params.name;
            this.chartDetail.queryInfo.seriesName = params.seriesName;
            this.chartDetail.title = `【${params.name}】【${params.seriesName}】明细`;
            this.chartDetail.dialogVisiable = true;
            this.getReworkChartDetail();
          })
        },
        // 返修明细
        async getReworkChartDetail() {
          this.currentDialog = 'getReworkChartDetail';
          this.getDetailCommon({ action: 'getReworkChartDetail', data: { ...this.queryInfo, ...this.chartDetail.queryInfo } });
        },
        // 合格率统计
        async getPassRate() {
          const loadingOption = { text: '数据查询中...', effect: 'whirling', maskColor: 'transparent', textColor: '#fff', color: '#66b1ff' };
          echarts.dispose(document.getElementById("passRateChart"));
          let chart = echarts.init(document.getElementById('passRateChart'));
          chart.showLoading(loadingOption);
          const { data: { data, meta, total } } = await axios.post('../handler/board/QualityDashBoard.ashx?action=getPassRate', {
            type: 'getPassRate',
            ...this.queryInfo
          })

          chart.hideLoading();
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          if (data.length === 0) { return; }

          echarts.dispose(document.getElementById("passRateChart"));
          chart = echarts.init(document.getElementById('passRateChart'));

          let arrWorkcenter = [], arrPassRate = [], arrNotPassRate = [];
          for (const i of data) {
            arrWorkcenter.push(i.workcentername);
            arrPassRate.push(i.passrate);
            arrNotPassRate.push(i.notpassrate);
          }

          let option = barOption({ isLableFormat: true, provideNumber: 4 });
          option.legend.data = ['合格率', '不合格率'];//设置图例文字
          option.yAxis[0].axisLabel.formatter = function (data) { return data + "%"; };//y轴文字追加%
          option.xAxis.data = arrWorkcenter;//x轴数据

          const { color, colorStops } = colorList.green;
          option.series[0] = _.merge(option.series[0], {
            name: '合格率', data: arrPassRate,
            label: { color: color, formatter: '{c}%' },
            itemStyle: { color: { colorStops: colorStops } }
          });

          option.series[1] = _.merge(_.cloneDeep(option.series[0]), {
            name: '不合格率',
            data: arrNotPassRate,
            type: 'line',
            symbolSize: 8,
            yAxisIndex: 1,
            label: {
              color: colorList.red.color,
              formatter: '{c}%'
            },
            lineStyle: { width: 3, color: colorList.red.color },
            itemStyle: { color: { colorStops: colorList.red.colorStops } }
          });

          chart.setOption(option);
          chart.on('click', (params) => {
            if (params.value == 0) { return; }
            this.chartDetail.queryInfo.currentPage = 1;
            this.chartDetail.queryInfo.workcentername = params.name;
            this.chartDetail.queryInfo.seriesName = params.seriesName;
            this.chartDetail.title = `【${params.name}】【${params.seriesName}】明细`
            this.chartDetail.dialogVisiable = true
            this.getPassRateDetail();
          })
        },
        // 合格率明细
        async getPassRateDetail() {
          this.currentDialog = 'getPassRateDetail';
          this.getDetailCommon({ action: 'getPassRateDetail', data: { ...this.queryInfo, ...this.chartDetail.queryInfo } });
        },
        // 一次交检合格率
        async getYiCiJiaoJianHeGeLv() {
          let { data, chart } = await this.getChartDataCommon({ id: 'YiCiJiaoJianHeGeLv', action: 'getYiCiJiaoJianHeGeLv', data: this.queryInfo });
          let arrWorkcenter = [], arrPassRate = [], arrNotPassRate = [];
          if (!data) { return; }
          for (const i of data) {
            arrWorkcenter.push(i.workcentername);
            arrPassRate.push(i.passrate);
            arrNotPassRate.push(i.notpassrate);
          }

          let option = barOption({ isLableFormat: true, provideNumber: 4 });
          option.legend.data = ['合格率', '不合格率'];//设置图例文字
          option.yAxis[0].axisLabel.formatter = function (data) { return data + "%"; };//y轴文字追加%
          option.xAxis.data = arrWorkcenter;//x轴数据

          const { color, colorStops } = colorList.green;
          option.series[0] = _.merge(option.series[0], {
            name: '合格率', data: arrPassRate,
            label: { color: color, formatter: '{c}%' },
            itemStyle: { color: { colorStops: colorStops } }
          });

          option.series[1] = _.merge(_.cloneDeep(option.series[0]), {
            name: '不合格率',
            data: arrNotPassRate,
            type: 'line',
            symbolSize: 8,
            yAxisIndex: 1,
            label: {
              color: colorList.red.color,
              formatter: '{c}%'
            },
            lineStyle: { width: 3, color: colorList.red.color },
            itemStyle: { color: { colorStops: colorList.red.colorStops } }
          });

          chart.setOption(option);
          chart.on('click', (params) => {
            if (params.value == 0) { return; }
            this.yiCiJiaoJianHeGeLvDetail.queryInfo.currentPage = 1;
            this.yiCiJiaoJianHeGeLvDetail.queryInfo.workcentername = params.name;
            this.yiCiJiaoJianHeGeLvDetail.queryInfo.seriesName = params.seriesName;
            this.yiCiJiaoJianHeGeLvDetail.title = `【${params.name}】【${params.seriesName}】明细`;
            this.yiCiJiaoJianHeGeLvDetail.dialogVisiable = true;
            this.getYiCiJiaoJianHeGeLvDetail();
          })
        },
        // 一次交检合格率--批次明细
        async getYiCiJiaoJianHeGeLvDetail() {
          this.loading = true
          this.loadingText = '数据加载中...'
          const { data: { data, meta, total } } = await axios.post(`../handler/board/QualityDashBoard.ashx?action=getYiCiJiaoJianHeGeLvDetail`, {
            type: 'getYiCiJiaoJianHeGeLvDetail',
            ...this.queryInfo,
            ...this.yiCiJiaoJianHeGeLvDetail.queryInfo
          });
          this.loading = false;
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.yiCiJiaoJianHeGeLvDetail.dataList = data;
          this.yiCiJiaoJianHeGeLvDetail.total = total;
        },
        // 一次交检合格率--批次工序明细
        async showNoPassSpecDetail(row) {
          this.noPassSpecDetail.dialogVisiable = true;
          this.noPassSpecDetail.queryInfo.workcentername = row.workcentername;
          this.noPassSpecDetail.queryInfo.seriesName = row.status;
          this.noPassSpecDetail.title = `【${row.containername}】不合格工序明细`;

          this.loading = true;
          this.loadingText = '数据加载中...';
          const { data: { data, meta, total } } = await axios.post(`../handler/board/QualityDashBoard.ashx?action=getNoPassSpecDetail`, {
            type: 'getNoPassSpecDetail',
            ...this.queryInfo,
            ...this.noPassSpecDetail.queryInfo
          });
          this.loading = false;
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.noPassSpecDetail.dataList = data;
        },
        // 成品检验合格率
        async getFinishCheckPassRate() {
          let { data, chart } = await this.getChartDataCommon({ id: 'finishCheckPassRate', action: 'getFinishCheckPassRate', data: this.queryInfo });
          let arrWorkcenter = [], arrPassRate = [], arrNotPassRate = [];
          if (!data) { return; }
          for (const i of data) {
            arrWorkcenter.push(i.workcentername);
            arrPassRate.push(i.passrate);
            arrNotPassRate.push(i.notpassrate);
          }

          let option = barOption({ isLableFormat: true, provideNumber: 4 });
          option.legend.data = ['合格率', '不合格率'];//设置图例文字
          option.yAxis[0].axisLabel.formatter = function (data) { return data + "%"; };//y轴文字追加%
          option.xAxis.data = arrWorkcenter;//x轴数据

          const { color, colorStops } = colorList.green;
          option.series[0] = _.merge(option.series[0], {
            name: '合格率', data: arrPassRate,
            label: { color: color, formatter: '{c}%' },
            itemStyle: { color: { colorStops: colorStops } }
          });

          option.series[1] = _.merge(_.cloneDeep(option.series[0]), {
            name: '不合格率',
            data: arrNotPassRate,
            type: 'line',
            symbolSize: 8,
            yAxisIndex: 1,
            label: {
              color: colorList.red.color,
              formatter: '{c}%'
            },
            lineStyle: { width: 3, color: colorList.red.color },
            itemStyle: { color: { colorStops: colorList.red.colorStops } }
          });

          chart.setOption(option);
          chart.on('click', (params) => {
            if (params.value == 0) { return; }
            this.finishCheckPassRateDetail.queryInfo.currentPage = 1;
            this.finishCheckPassRateDetail.queryInfo.workcentername = params.name;
            this.finishCheckPassRateDetail.queryInfo.seriesName = params.seriesName;
            this.finishCheckPassRateDetail.title = `【${params.name}】【${params.seriesName}】明细`;
            this.finishCheckPassRateDetail.dialogVisiable = true;
            this.getFinishCheckPassRateDetail();
          })
        },
        // 成品检验合格率--明细
        async getFinishCheckPassRateDetail() {
          this.loading = true;
          this.loadingText = '数据加载中...';
          const { data: { data, meta, total } } = await axios.post(`../handler/board/QualityDashBoard.ashx?action=getFinishCheckPassRateDetail`, {
            type: 'getFinishCheckPassRateDetail',
            ...this.queryInfo,
            ...this.finishCheckPassRateDetail.queryInfo
          });
          this.loading = false;
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.finishCheckPassRateDetail.dataList = data;
          this.finishCheckPassRateDetail.total = total;
        },
        factorySeletChange() {
          this.queryInfo.factoryname = this.factoryList.filter(item => item.factoryid === this.queryInfo.factoryid)[0].factoryname;
          this.title = `${this.queryInfo.factoryname}质量看板`;
          document.title = this.title;
        },
        handlerBtnSearch() {
          this.$refs['queryInfoRef'].validate(async (valid) => {
            if (!valid) { return this.$message.error('必填项不能为空'); }
            this.getPassRate();
            this.getDefectQtyChart();
            this.getReworkQtyChart();
            this.getLossQtyChart();
            this.getYiCiJiaoJianHeGeLv();
            this.getFinishCheckPassRate();
          })
        },
        handleDetailCurrentChange(newPage) {
          this.chartDetail.queryInfo.currentPage = newPage;
          switch (this.currentDialog) {
            case "getLossChartDetail":
              this.getLossChartDetail();
              break;
            case "getDefectChartDetail":
              this.getDefectChartDetail();
              break;
            case "getReworkChartDetail":
              this.getReworkChartDetail();
              break;
            case "getPassRateDetail":
              this.getPassRateDetail();
              break;
          }
        },
        // 一次交检合格率--批次明细
        handleYiCiJiaoJianHeGeLvDetailCurrentChange(newPage) {
          this.yiCiJiaoJianHeGeLvDetail.queryInfo.currentPage = newPage;
          this.getYiCiJiaoJianHeGeLvDetail();
        },
        // 成检合格率--明细
        handleFinishCheckPassRateDetailCurrentChange(newPage) {
          this.finishCheckPassRateDetail.queryInfo.currentPage = newPage;
          this.getFinishCheckPassRateDetail();
        }
      },
      async mounted() {
        this.chartHeight = (window.innerHeight - 110 - this.chartRow * 40) / this.chartRow;
        let incrementNumber = () => {
          setTimeout(incrementNumber, 500);
          this.currentTime = dayjs().format('YYYY年MM月DD日  HH:mm:ss');
        }
        setTimeout(incrementNumber, 500);
        const today = dayjs().format('YYYY-MM-DD');
        const startOfThisMonth = dayjs().startOf('month').format('YYYY-MM-DD');
        const endOfThisMonth = dayjs().endOf('month').format('YYYY-MM-DD');
        this.queryInfo.selectdate = [startOfThisMonth, endOfThisMonth];

        this.factoryList = await getFactoryListByCode({ factoryCode: '604|601|607|609|600|608|602' });
        this.userInfo = await getUserInfo({ employeeid: getParams("uid") });

        if (this.userInfo.factoryid && this.factoryList.some(item => item.factoryid === this.userInfo.factoryid)) {
          const { factoryid, factoryname } = this.userInfo;
          this.queryInfo.factoryid = factoryid
          this.queryInfo.factoryname = factoryname
        } else {
          this.queryInfo.factoryid = this.factoryList[0].factoryid;
          this.queryInfo.factoryname = this.factoryList[0].factoryname;
        }
        this.title = `${this.queryInfo.factoryname}质量看板`;
        document.title = this.title;

        this.getPassRate();
        this.getDefectQtyChart();
        this.getReworkQtyChart();
        this.getLossQtyChart();
        this.getYiCiJiaoJianHeGeLv();
        this.getFinishCheckPassRate();
      }
    })
  </script>
</body>

</html>